package main

import (
	"counter/counter"
	"fmt"
	"time"
)

func main() {
	c:= counter.NewCounter2()
	c.InitIncr(50, "test") //初始化为50ms清空一次
	fmt.Println(c.Query("test"))   //50ms时 初始
	c.Cnt("test", 100)
	fmt.Println(c.Query("test"))   // 计数100,测试
	time.Sleep(1*time.Second)           //休眠1s , 1s > 50ms ,测试清空
	fmt.Println("清空 ",c.Query("test"))     //清空
	c.InitIncr(1500,"t1") //测试两个计数器的key
	c.InitIncr(2000,"test") //测试两个计数器的key
	fmt.Println(c.Query("t1"),c.Query("test"))
	c.Cnt("test",100)
	c.Cnt("t1",150)
	fmt.Println(c.Query("t1"),c.Query("test"))
	time.Sleep(1*time.Second)
	fmt.Println(c.Query("t1"),c.Query("test"))
	c.Exit()
}
